package program;

import kernel.IOManager;
import kernel.ProcessManager;
import kernel.exception.OSException;
import kernel.process.AbstractProcess;
import kernel.process.AbstractProcessHeader;

/**
 * Shutdown process.
 * For more see man() method.
 * @author Jaromir Lepic, Veronika Vencurikova
 *
 */
public class Shutdown extends AbstractProcess {

	public Shutdown(AbstractProcessHeader header, long pid) {
		super(header, pid);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String continueJob() throws OSException {
		shouldEnd = true;
		return null;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected String finalizeJob() throws OSException {
		return null;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected String doJob(String input) throws OSException {
		ProcessManager.getInstance().shutdown();
		IOManager.getInstance().shutdownWindows();
		return null;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean needParams() {
		return false;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	protected void kill() throws OSException {

	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String man(String command) {
	String man = "";
		
		man += "    shuts the system down\n";
		man += "\n";
		man += "Command syntax:\n";
		man += "    shutdown\n";
		
		return man;
	}

}
